package _15_竞赛练习;

public class _2016_增量元素之间的最大差值 {

    public static void main(String[] args) {

        _2016_增量元素之间的最大差值 v = new _2016_增量元素之间的最大差值();

        int[] ins = new int[]{9, 4, 3, 2};
        System.out.println(v.maximumDifference(ins));
    }

    public int maximumDifference(int[] nums) {
        int max = -1;
        int min = nums[0];
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] > min) {
                max = Math.max(max, nums[i] - min);
            } else {
                min = nums[i];
            }
        }
        return max;
    }

}
